package com.ruoyi.module.szLiveApply.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.module.szLiveApply.domain.SzLiveApply;
import com.ruoyi.module.szLiveApply.service.ISzLiveApplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 直播申请Controller
 * 
 * @author yqq
 * @date 2023-10-19
 */
@RestController
@RequestMapping("/module/szLiveApply")
public class SzLiveApplyController extends BaseController
{
    @Autowired
    private ISzLiveApplyService szLiveApplyService;

    /**
     * 查询直播申请列表
     */
    @PreAuthorize("@ss.hasPermi('module:szLiveApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(SzLiveApply szLiveApply)
    {
        startPage();
        List<SzLiveApply> list = szLiveApplyService.selectSzLiveApplyList(szLiveApply);
        return getDataTable(list);
    }

    /**
     * 导出直播申请列表
     */
    @PreAuthorize("@ss.hasPermi('module:szLiveApply:export')")
    @Log(title = "直播申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SzLiveApply szLiveApply)
    {
        List<SzLiveApply> list = szLiveApplyService.selectSzLiveApplyList(szLiveApply);
        ExcelUtil<SzLiveApply> util = new ExcelUtil<SzLiveApply>(SzLiveApply.class);
        return util.exportExcel(list, "直播申请数据");
    }

    /**
     * 获取直播申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:szLiveApply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(szLiveApplyService.selectSzLiveApplyById(id));
    }

    /**
     * 新增直播申请
     */
    @PreAuthorize("@ss.hasPermi('module:szLiveApply:add')")
    @Log(title = "直播申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SzLiveApply szLiveApply)
    {
        return toAjax(szLiveApplyService.insertSzLiveApply(szLiveApply));
    }

    /**
     * 修改直播申请
     */
    @PreAuthorize("@ss.hasPermi('module:szLiveApply:edit')")
    @Log(title = "直播申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SzLiveApply szLiveApply)
    {
        return toAjax(szLiveApplyService.updateSzLiveApply(szLiveApply));
    }

    /**
     * 删除直播申请
     */
    @PreAuthorize("@ss.hasPermi('module:szLiveApply:remove')")
    @Log(title = "直播申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(szLiveApplyService.deleteSzLiveApplyByIds(ids));
    }
}
